<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="apple-mobile-web-app-title" content="阿福易购">
    <meta content="telephone=no" name="format-detection" />
    <meta content="email=no" name="format-detection" />
    <!-- uc、qq浏览器 -->
    <meta name="screen-orientation" content="portrait">
    <meta name="full-screen" content="yes">
    <meta name="browsermode" content="application">
    <meta name="x5-orientation" content="portrait">
    <meta name="x5-fullscreen" content="true">
    <meta name="x5-page-mode" content="app">
    <meta name="HandheldFriendly" content="true">
    <meta name="MobileOptimized" content="320">
    <meta name="csrf-token" content="{{ csrf_token() }}" />
    <meta name="keywords" content="{{$SEO['keywords']}}"/>
    <meta name="description" content="{{$SEO['description']}}"/>
    <title>购物车_{{$SEO['title']}}</title>
    <link rel="stylesheet" href="{{ asset('/build/css/app.min.css') }}">
</head>

@inject('pictureService','App\Interfaces\PictureService')

<body ontouchstart="" class="no-goTop">
<header class="ui-header ui-header-stable  af-header">
    <ul class="ui-row-flex">
        <li class="ui-col ui-flex ui-flex-pack-start">
            <i ontouchstart="window.history.back()" class="ui-icon-return"></i>
        </li>
        <li class="ui-col ui-flex ui-flex-pack-center">
            <h1>购物车</h1>
        </li>
        <li class="ui-col ui-flex ui-flex-pack-end">
            <i data-href="/" class="ui-icon-home"></i>
        </li>
    </ul>
</header>

<div class="ui-container ui-cart-container">

@if($cart['total_number'])

    <!--E贸易商品-->
    @if($cart['eshopGoods']['total_number'])

    <?php
        $onSaleNum=0;

        //遍历E贸易商品中的非下架商品
        if($cart['eshopGoods']['total_number']>1&&$cart['eshopGoods']['total_price']>1000){
            foreach($cart['eshopGoods']['shopGoods'] as $curGoods){
                if( $curGoods['deleted_at']|| $curGoods['is_on_sale']==2 || $curGoods['goods_number'] == 0){
                    continue;
                }
                $onSaleNum=$onSaleNum+$curGoods['buy_num'];
            }
        }

        $showTotalWarning=$onSaleNum>1;
    ?>
    <div class="ui-form ui-cart-one" data-type="eShop">
        <div class="ui-form-item ui-form-item-checkbox af-border-b">
            <label class="ui-checkbox">
                <input class="J-checkAll" type="checkbox">
            </label>
            <p>E贸易商品</p>
        </div>

        <ul class="ui-list ui-list-text ui-list-checkbox af-border-b">

        @foreach($cart['eshopGoods']['shopGoods'] as $egoodsIndex=>$egoods)
            <?php

                $shuiPercent= ($egoods['excise_duty_percent']+$egoods['value_added_tax_percent'])*0.7;
            ?>

            <li class="li-item @if($egoods->discount) li-item-hasCoupon @endif @if($egoodsIndex>0) af-border-t @endif @if($egoods['goods_number']==0||$egoods['is_on_sale']==2||!empty($egoods['deleted_at'])) ui-goods-disabled @endif" data-id="{{$egoods['goods_id']}}">

                    @if($egoods->discount)
                    <h2 class="ui-cart-coupon af-border-b">
                        <label class="ui-label-s ui-label-light">折扣</label>
                        <span>
                        <?php
                        //dd($egoods);
                        //可用类型，1：全场通用；2：商品；3：分类；4：店铺；5：品牌
                            switch ($egoods->discount['discount_type']) {
                                case '1':
                                    echo '全场通用';
                                    break;

                                case '2':
                                    echo '商品';
                                    break;

                                case '3':
                                    echo '分类';
                                    break;

                                case '4':
                                    echo '店铺';
                                    break;

                                case '5':
                                    echo '品牌';
                                    break;
                            }
                        ?>类型  {{$egoods->discount['discount_label']}}</span>
                    </h2>
                    @endif
                    <label class="ui-checkbox">
                        <input class="J-checkOne" type="checkbox" @if($egoods['goods_number']==0||$egoods['is_on_sale']==2||!empty($egoods['deleted_at'])) disabled @endif>
                    </label>
                    <div class="ui-list-thumb">
                        <span style="background-image:url({{$pictureService::thumb($egoods['goods_thumb'], 70, 70)}})" alt="{{$egoods['goods_name']}}"></span>
                    </div>
                    <div class="ui-list-info">
                        <h6 class="ui-nowrap"><a class="link" href="/goods/show/{{$egoods['goods_id']}}" title="{{$egoods['goods_name']}}">{{$egoods['goods_name']}}</a></h6>
                        @if(!empty($egoods['deleted_at']) || $egoods['is_on_sale']==2)
                            <small class="ui-txt-highlight">该商品已下架</small>
                        @elseif($egoods['goods_number']==0)
                            <small class="ui-txt-highlight">库存不足</small>
                        @else
                            <div class="ui-txt-info">
                                <div class="ui-num-plugin af-border-tb">
                                    <button class="af-border-l af-border-r ui-num-btn ui-num-min">-</button>
                                    <input class="ui-num-input" type="text" value="{{$egoods['buy_num']>$egoods['goods_number']?$egoods['goods_number']:$egoods['buy_num']}}" min="1" max="{{$egoods['goods_number']}}" readonly>
                                    <button class="af-border-l af-border-r ui-num-btn ui-num-add">+</button>
                                </div>
                            </div>
                            @if($egoods['goods_number'] < 10)
                                <small class="text-color-1">(库存{{$egoods['goods_number']}}件)</small>
                            @endif
                        @endif

                    </div>
                    <div class="ui-cart-goods-opts">
                        <p><small>¥</small>{{$egoods['goods_real_price']}} </p>
                        <i class="ui-icon-delete"></i>
                    </div>
                </li>
        @endforeach
        </ul>

        <section class="ui-panel ui-cart-calculate">
            <p class="t-price">
                <span>已选商品<i class="J-totalNum">0</i>件商品</span>
                <span class="r">商品总额：<span class="val">¥ <span class="J-totalPrice">0.00</span></span></span>
            </p>
            <p>
                <span class="r">关税：<span class="val">¥ <span class="J-tariff">0.00</span></span></span>
            </p>
            <p class="total">
                <span class="r">总计(不含运费)：<span class="val">¥ <span class="J-payPrice">0.00</span></span></span>
            </p>
            <p>
                <span class="r">
                    <a class="J-toPay ui-btn ui-btn-lg">结算</a>
                </span>
            </p>
        </section>

        <div class="J-PurchaseTip ui-tips ui-tips-warn af-hide">
            <i></i>
            <p>啊哦，海关规定购买多件的总价（不含税）不能超过¥1000哦，请您分多次购买。</p>
        </div>

    </div>
    @endif


    @if($cart['cshopGoods']['total_number']>0)
    <div class="ui-form ui-cart-one" data-type="cShop">
        <div class="ui-form-item ui-form-item-checkbox af-border-b">
            <label class="ui-checkbox">
                <input class="J-checkAll" type="checkbox">
            </label>
            <p>免税商品</p>
        </div>

        <ul class="ui-list ui-list-text ui-list-checkbox af-border-b">
            @foreach($cart['cshopGoods']['shopGoods'] as $goodsIndex=>$goods)

            <li class="li-item @if($goods->discount) li-item-hasCoupon @endif @if($goodsIndex>0) af-border-t @endif @if($goods['goods_number']==0||$goods['is_on_sale']==2||!empty($goods['deleted_at'])) ui-goods-disabled @endif" data-id="{{$goods['goods_id']}}">

                @if($goods->discount)
                <h2 class="ui-cart-coupon af-border-b">
                    <label class="ui-label-s ui-label-light">折扣</label>
                    <span>
                    <?php
                    //可用类型，1：全场通用；2：商品；3：分类；4：店铺；5：品牌
                        switch ($goods->discount['discount_type']) {
                            case '1':
                                echo '全场通用';
                                break;

                            case '2':
                                echo '商品';
                                break;

                            case '3':
                                echo '分类';
                                break;

                            case '4':
                                echo '店铺';
                                break;

                            case '5':
                                echo '品牌';
                                break;
                        }
                    ?>类型  {{$goods->discount['discount_label']}}</span>
                </h2>
                @endif
                <label class="ui-checkbox">
                    <input class="J-checkOne" type="checkbox"  @if($goods['goods_number']==0||$goods['is_on_sale']==2||!empty($goods['deleted_at'])) disabled @endif>
                </label>
                <div class="ui-list-thumb">
                    <span style="background-image:url({{$pictureService::thumb($goods['goods_thumb'], 70, 70)}})" alt="{{$goods['goods_name']}}"></span>
                </div>
                <div class="ui-list-info">
                    <h6 class="ui-nowrap"><a class="link" href="/goods/show/{{$goods['goods_id']}}" title="{{$goods['goods_name']}}">{{$goods['goods_name']}}</a></h6>
                    <div class="ui-txt-info">
                        @if(!empty($goods['deleted_at']) || $goods['is_on_sale']==2)
                            <small class="ui-txt-highlight">该商品已下架</small>
                        @elseif($goods['goods_number']==0)
                            <small class="ui-txt-highlight">库存不足</small>
                        @else
                            <div class="ui-num-plugin af-border-tb">
                                <button class="af-border-l af-border-r ui-num-btn ui-num-min">-</button>
                                <input class="ui-num-input" type="text" value="{{$goods['buy_num']>$goods['goods_number']?$goods['goods_number']:$goods['buy_num']}}" min="1" max="{{$goods['goods_number']}}" readonly>
                                <button class="af-border-l af-border-r ui-num-btn ui-num-add">+</button>
                            </div>
                            @if($goods['goods_number'] < 10)
                                <small class="text-color-1">(库存{{$goods['goods_number']}}件)</small>
                            @endif
                        @endif
                    </div>
                </div>
                <div class="ui-cart-goods-opts">
                    <p><small>¥</small>{{$goods['goods_real_price']}} </p>
                    <!-- <p>×1</p> -->
                    <i class="ui-icon-delete"></i>
                </div>
            </li>
            @endforeach
        </ul>

        <section class="ui-panel ui-cart-calculate">
            <p class="t-price">
                <span>已选商品<i class="J-totalNum">0</i>件商品</span>
                <span class="r">商品总额：<span class="val">¥<span class="J-totalPrice">0.00</span></span></span>
            </p>
            <p>
                <span class="r">关税：<span class="val">¥<span class="J-tariff">0.00</span></span></span>
            </p>
            <p class="total">
                <span class="r">总计(不含运费)：<span class="val">¥ <span class="J-payPrice">0.00</span></span></span>
            </p>
            <p>
                <span class="r">
                    <a class="J-toPay ui-btn ui-btn-lg">结算</a>
                </span>
            </p>
        </section>

    </div>
    @endif


@else
    <section class="ui-cart-nodata">
        <i class="ui-icon-cart"></i>
        <small class="af-txt-muted">购物车里空空如也，赶紧去逛逛吧！</small>
        <p><a class="ui-btn ui-btn-sm" href="/">去逛逛</a></p>
    </section>
@endif
</div>

<script src="{{ asset('/build/lib/zepto.min.js') }}"></script>
<script src="{{ asset('/build/js/frozen.js') }}"></script>
<script src="{{ asset('/build/js/app.min.js') }}"></script>
<script>
    //购物车
    var timestamp=new Date().getTime();
    var options={
        delUrl:'/cart/'+timestamp,//删除请求url
        url:'/cart/getGoodsInfo',//统计信息url
        payUrl:'/cart/settlement',//验证下单信息url
        orderUrl:'/order'//跳转订单页面url
    };
    var listHandler=new ListHandler(options);
</script>

</body>
</html>